<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Load Image Promise</title>
</head>
<body>
  <script src="./loadImage.js"></script>
  <script>
    const loadImagePromise = function (src) {
      return new Promise((resolve, reject) => {
        loadImage(src, function (err, image) {
          if (err) {
            reject(err)
            return
          }
          resolve(image)
        })
      })
    }

    loadImagePromise(imageSrc).then(res => {
      console.log(res);
    }).catch(err => {
      console.log(err);
    })
  </script>
</body>
</html>